package com.tradeplus.admin.dao;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.tradeplus.admin.model.City;

public class CityDaoImpl implements CityDao {
	
	private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

	@Override
	public void saveCity(City city) {
		hibernateTemplate.merge(city);
		
	}

	@Override
	public List<City> loadCity() {
		return hibernateTemplate.find("from City");
	}

	@Override
	public void deleteCity(Long cityId) {
		hibernateTemplate.delete(hibernateTemplate.get(City.class, cityId));
	}

	@Override
	public City loadCityById(Long cityId) {
		return (City) hibernateTemplate.get(City.class, cityId);
	}

}
